<template>
  <el-container style="min-height: 100vh; background-color: #f5f7fa; display: flex; align-items: center; justify-content: center;">
    <el-card style="width: 600px; padding: 30px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);">
      <h2 style="margin-bottom: 10px;">请选择报表类型</h2>
      <p style="color: #666; margin-bottom: 30px;">您可以查看实时数据报表或下载定时报表文件</p>

      <el-row :gutter="20">
        <!-- 实时报表 -->
        <el-col :span="12">
          <div
            class="report-card"
            @click="handleExcel()"
            style="cursor: pointer;"
          >
            <i class="el-icon-s-data" style="font-size: 40px; color: #409EFF;"></i>
            <h4 style="margin: 15px 0;">实时报表</h4>
            <p style="color: #888; font-size: 14px;">查看当前最新数据统计信息</p>
          </div>
        </el-col>

        <!-- 定时报表 -->
        <el-col :span="12">
          <div
            class="report-card"
            @click="$router.push('/statistics/excel')"
            style="cursor: pointer;"
          >
            <i class="el-icon-tickets" style="font-size: 40px; color: #67C23A;"></i>
            <h4 style="margin: 15px 0;">定时报表</h4>
            <p style="color: #888; font-size: 14px;">下载历史定时生成的报表文件</p>
          </div>
        </el-col>
      </el-row>
    </el-card>
  </el-container>
</template>

<script>
import { exportExcel } from '@/api/statistics';
export default {
  name: 'Choice',
  data(){
    return {
      
    }
  },
  methods: {
    
    handleExcel() {
      exportExcel()
        .then(response => {
          if(response.code === 200){
            this.$message({
              message: "下载成功!",
              type: 'success'
            });
        }})
        .catch(error => {
           this.$message({
              message: response.message,
              type: 'error'
            });
        })
    }
  }
}
</script>

<style scoped>
.report-card {
  padding: 20px;
  border-radius: 8px;
  background-color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  height: 100%;
}

.report-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}
</style>
